package com.dudu.service.impl;

import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import com.dudu.access.ImsVoiceNoticeUtils;
import com.dudu.bean.AccountBean;
import com.dudu.bean.AppExtendBean;
import com.dudu.bean.ChargingRuleBean;
import com.dudu.bean.IfControlBean;
import com.dudu.bean.PoolAbilityInfoBean;
import com.dudu.bean.ResponseSendVoiceBean;
import com.dudu.dao.SendNoticeDao;
import com.dudu.enumeration.AbilityTypeEnum;
import com.dudu.model.SendNotice;
import com.dudu.service.IInfoControl;
import com.dudu.service.IRuleService;
import com.dudu.service.IVoiceNoticeService;
import com.dudu.timer.SendVoiceUtil;

import core.CoreDao;
import core.CoreDaoInvoke;

/**
 * 语音短信
 * 
 * @author jack
 * @date 2017-3-15
 */
public class VoiceNoticeServiceImpl implements IVoiceNoticeService {

    private static final Logger log = core.util.Logger.getLogger(VoiceNoticeServiceImpl.class.getSimpleName());
    // 用于查询数据用
    private CoreDao coreDao = CoreDaoInvoke.getInstance();
    // 语音信息
    private SendNoticeDao mSendNoticeDao = new SendNoticeDao();

    /**
     * 发起语音短信
     * 
     * @param appExtendBean
     *            应用信息
     * @param accountBean
     *            账号信息
     * @param userIdentify
     *            用户标识
     * @param caller
     *            主叫号码
     * @param called
     *            被叫号码
     * @param content
     *            短信内容
     * @param schedule_send_time
     *            预定短信发起时间
     * @param push_url
     *            语音通信预约后，通信发起sessionid接收地址
     * @param tts_content
     *            前导音
     * @param pool_ability_id
     *            ISV自定义发起留言使用号码
     * @param batch_number
     *            是否一批次
     * @param usePlatNbr
     *            强制使用平台号
     * @return
     */
    @Override
    public JSONObject sendVoiceNotice(AppExtendBean appExtendBean, AccountBean accountBean, String userIdentify, String caller, String called, String content,
	    String schedule_send_time, String push_url, String tts_content, String pool_ability_id, String batch_number, String usePlatNbr, JSONArray calledJsonArray,
	    String abilityType) {
	log.info("VoiceNoticeServiceImpl.sendVoiceNotice 发起语音短信");
	// 最终返回结果
	JSONObject object = new JSONObject();
	// 处理上传的文字信息
	content = content.replaceAll("\\pP|\\pS", " ");
	// 处理前导音的标点
	tts_content = tts_content.replaceAll("\\pP|\\pS", " ");
	// 处理上传的文字的空格信息
	content = content.replaceAll(" ", ";");
	// 处理前导音的空格
	tts_content = tts_content.replaceAll(" ", ";");
	// 能力配置查询
	IRuleService ruleService = new RuleServiceImpl();
	ChargingRuleBean chargingRule = ruleService.queryChargingRule(appExtendBean.getApp_key(), accountBean.getCust_account(), abilityType);
	// 判断查询的默认通道调用数据是否为空
	if (chargingRule != null) {
	    // 判断如果传入的时间为空，则默认使用当前时间+3分钟
	    if (chargingRule.getType().contains("YonYou")) { // 自建通道设置为空发，SendVoiceUtil.java类统一处理发送时间
		if (schedule_send_time == null || schedule_send_time.equals("") || schedule_send_time.equals("null")) {
		    schedule_send_time = "";
		}
	    } else {
		if (schedule_send_time == null || schedule_send_time.equals("") || schedule_send_time.equals("null")) {
		    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		    Date now = new Date();
		    Date nowAdd = new Date(now.getTime() + 3 * 60 * 1000);
		    schedule_send_time = format.format(nowAdd);
		}
	    }

	    String displayNum = null;// 显号
	    String number_vest = null;// 地区
	    SendVoiceUtil sendUtil = new SendVoiceUtil();
	    PoolAbilityInfoBean poolAbilityInfo = sendUtil.queryPoolAbilityInfo(coreDao, appExtendBean.getApp_key(), accountBean.getCust_account(), chargingRule.getType(),
		    pool_ability_id, displayNum, usePlatNbr, number_vest);
	    if (poolAbilityInfo == null) {
		if (chargingRule.getType().startsWith("RongLian")) {
		    poolAbilityInfo = new PoolAbilityInfoBean();
		} else {
		    object.put("result", "-1");
		    object.put("errorMsg", "未配置对应显号;ability_type:" + chargingRule.getType());
		    object.put("describe", "未配置显号");
		    object.put("code", "0018");
		    return object;
		}
	    }

	    // 根据查询的账户默认调用的能力配置，调用相应的通道
	    // 判断如果是ims文字语音信息，则调用ims文字语音信息接口
	    if (AbilityTypeEnum.VOICENOTICE3.getKey().equals(chargingRule.getType())) {
		// IMS进行相应业务处理
		object = sendNoticeIms(appExtendBean, accountBean, userIdentify, caller, called, poolAbilityInfo.getCharge_number(), poolAbilityInfo.getCharge_key(),
			poolAbilityInfo.getDisplay_number(), content, schedule_send_time, push_url, tts_content, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("RongLian")) {
		// 容联文字语音通知
		object = this.sendNotice(appExtendBean, accountBean, chargingRule.getType(), userIdentify, caller, called, poolAbilityInfo, content, schedule_send_time, push_url,
			tts_content, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("TianYi")) {
		// 天亿文字语音通知
		object = this.sendNotice(appExtendBean, accountBean, chargingRule.getType(), userIdentify, caller, called, poolAbilityInfo, content, schedule_send_time, push_url,
			tts_content, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("TianRun")) {
		// 天润文字语音通知
		object = this.sendNotice(appExtendBean, accountBean, chargingRule.getType(), userIdentify, caller, called, poolAbilityInfo, content, schedule_send_time, push_url,
			tts_content, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("YonYou")) {
		// 自建平台语音通知
		object = this.sendNotice(appExtendBean, accountBean, chargingRule.getType(), userIdentify, caller, called, poolAbilityInfo, content, schedule_send_time, push_url,
			tts_content, batch_number, calledJsonArray);
	    } else {
		object.put("result", "-1");
		object.put("errorMsg", "未配置默认文字语音信息通道！voice_type:" + chargingRule.getType());
		object.put("describe", "未配置线路");
		object.put("code", "0010");
	    }
	    /**
	     * 发起成功后调用信控入口服务 需要同时满足以下几个条件 1）语音通知发起成功 2）批次号不能为空
	     */
	    /*try {

		if (StringUtils.isNotEmpty(batch_number) && "0".equals(object.getString("result"))) {
		    String voiceIds = object.getString("voice_id");
		    if (StringUtils.isNotEmpty(voiceIds)) {
			String[] calleds = called.split(",");
			JSONObject voices = JSONObject.fromObject(voiceIds);
			String voiceId = voices.getString(calleds[0]);
			IInfoControl ifControl = new InfoControlServiceImpl();
			IfControlBean ifBean = new IfControlBean();
			ifBean.setProductCode(abilityType);
			ifBean.setAbilityType(chargingRule.getType());// 能力类型
			ifBean.setAppKey(appExtendBean.getApp_key());// 应用标识
			ifBean.setCustAccount(accountBean.getCust_account());// 计费账户
			ifBean.setUserIdentify(userIdentify);// 用户id
			ifBean.setBatchNumber(batch_number);// 批次号
			ifBean.setRequestCount(calleds.length);// 本次调用传入的手机号数量
			Map<String, String> parameterMap = new HashMap<String, String>();
			parameterMap.put("voice_id", voiceId);// 调用重发接口
			parameterMap.put("source", poolAbilityInfo.getNumber_source());// 号码来源类型
			ifControl.infoControl(ifBean, parameterMap);
		    }
		}
	    } catch (Exception err) {
		log.error("信控监控异常", err);
	    }*/
	} else {
	    object.put("result", "-1");
	    object.put("describe", "能力配置错误");
	    object.put("code", "0013");
	}
	return object;
    }

    /**
     * IMS语音短信实际业务处理
     * 
     * @param appExtendBean
     *            应用信息
     * @param accountBean
     *            账号信息
     * @param userIdentify
     *            用户标识
     * @param caller
     *            主叫号码
     * @param called
     *            被叫号码
     * @param chargeNbr
     *            IMS发起账号
     * @param key
     *            IMS发起密码
     * @param displayNumber
     *            显号
     * @param content
     * @param schedule_send_time
     * @param push_url
     *            推送地址
     * @param tts_content
     *            前导音
     * @param batch_number
     *            是否一批次
     * @deprecated ims已停用
     * @return
     */
    private JSONObject sendNoticeIms(AppExtendBean appExtendBean, AccountBean accountBean, String userIdentify, String caller, String called, String chargeNbr, String key,
	    String displayNumber, String content, String schedule_send_time, String push_url, String tts_content, String batch_number, JSONArray calledJsonArray) {

	// 最终返回结果
	JSONObject object = new JSONObject();
	// 语音文字转化
	ResponseSendVoiceBean responseSendVoice = null;
	try {
	    responseSendVoice = ImsVoiceNoticeUtils.createTTSVoice(content);
	} catch (UnsupportedEncodingException e1) {
	    e1.printStackTrace();
	}

	if (!"0".equals(responseSendVoice.getResult())) {
	    object.put("result", "-1");
	    object.put("describe", "创建语音通知失败");
	    object.put("code", "0022");
	} else {
	    object.put("result", "0");
	    object.put("describe", "语音短信存储成功");
	    object.put("code", "0000");

	    JSONObject voiceAndSessionIds = SendVoiceUtil.saveNotices(called, AbilityTypeEnum.VOICENOTICE3.getKey(), appExtendBean.getApp_key(), caller, chargeNbr, key,
		    accountBean.getCust_account(), appExtendBean.getPeriphery_code(), userIdentify, schedule_send_time, "", content, responseSendVoice.getFileName(), push_url,
		    tts_content, displayNumber, batch_number, "-1", "", "", coreDao, calledJsonArray);
	    
	    /**
		 * qinfx 2017-05-22 新增返回session_id
		 */
		JSONObject voice_ids = voiceAndSessionIds.getJSONObject("voiceIds");
		JSONObject session_ids = voiceAndSessionIds.getJSONObject("sessionIds");

		// 拼入返回的会议id
		object.put("voice_id", voice_ids.toString());
		object.put("session_id", session_ids.toString());
	}

	return object;
    }

    /**
     * 语音短信实际业务处理
     * 
     * @param appExtendBean
     * @param accountBean
     * @param ability_type
     * @param userIdentify
     * @param caller
     * @param called
     * @param poolAbilityInfo
     * @param content
     * @param schedule_send_time
     * @param push_url
     * @param tts_content
     * @param batch_number
     * @param calledJsonArray
     * @return
     */
    private JSONObject sendNotice(AppExtendBean appExtendBean, AccountBean accountBean, String ability_type, String userIdentify, String caller, String called,
	    PoolAbilityInfoBean poolAbilityInfo, String content, String schedule_send_time, String push_url, String tts_content, String batch_number, JSONArray calledJsonArray) {
	// 最终返回结果
	JSONObject object = new JSONObject();
	object.put("result", "0");
	object.put("describe", "语音短信存储成功");
	object.put("code", "0000");
	JSONObject voiceAndSessionIds = SendVoiceUtil.saveNotices(called, ability_type, appExtendBean.getApp_key(), caller, poolAbilityInfo.getCharge_number(),
		poolAbilityInfo.getCharge_key(), accountBean.getCust_account(), appExtendBean.getPeriphery_code(), userIdentify, schedule_send_time, "", content, "", push_url,
		tts_content, poolAbilityInfo.getDisplay_number(), batch_number, "-1", "", "", coreDao, calledJsonArray);
    /**
	 * qinfx 2017-05-22 新增返回session_id
	 */
	JSONObject voice_ids = voiceAndSessionIds.getJSONObject("voiceIds");
	JSONObject session_ids = voiceAndSessionIds.getJSONObject("sessionIds");

	// 拼入返回的会议id
	object.put("voice_id", voice_ids.toString());
	object.put("session_id", session_ids.toString());
	return object;
    }

    /**
     * 重新发起语音短信
     * 
     * @param appExtendBean
     *            应用信息
     * @param accountBean
     *            账号信息
     * @param userIdentify
     *            用户标识
     * @param voice_id
     *            重发的信息的id
     * @param caller
     *            主叫号码
     * @param called
     *            被叫号码
     * @param schedule_send_time
     *            预定短信发起时间
     * @param push_url
     *            语音通信预约后，通信发起sessionid接收地址
     * @param tts_content
     *            前导音 如果设置前导音，则使用之前的前导音如果前导音设置为-1，则清空前导音
     * @param pool_ability_id
     *            ISV自定义发起留言使用号码
     * @param batch_number
     *            是否一批次
     * @param usePlatNbr
     *            强制使用平台号
     * @return
     */
    @Override
    public JSONObject sendVoiceNoticeLet(AppExtendBean appExtendBean, AccountBean accountBean, String userIdentify, String voice_id, String caller, String called,
	    String schedule_send_time, String push_url, String tts_content, String pool_ability_id, String batch_number, String usePlatNbr, JSONArray calledJsonArray,
	    String abilityType) {
	// 最终返回结果
	JSONObject object = new JSONObject();
	// 判断如果传入的时间为空，则默认使用当前时间
	if (schedule_send_time == null || schedule_send_time.equals("") || schedule_send_time.equals("null")) {
	    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    Date now = new Date();
	    schedule_send_time = format.format(now);
	}

	// 查询当前账号默认使用的多方通话能力通道
	// 获取语音短信能力类型标识
	// String abilityType=AbilityTypeEnum.VOICE.getKey();
	// 能力配置查询
	IRuleService ruleService = new RuleServiceImpl();
	ChargingRuleBean chargingRule = ruleService.queryChargingRule(appExtendBean.getApp_key(), accountBean.getCust_account(), abilityType);
	// 判断查询的默认通道调用数据是否为空
	if (chargingRule != null) {
	    String displayNum = null;// 显号
	    String number_vest = null;// 地区
	    SendVoiceUtil sendUtil = new SendVoiceUtil();
	    PoolAbilityInfoBean poolAbilityInfo = sendUtil.queryPoolAbilityInfo(coreDao, appExtendBean.getApp_key(), accountBean.getCust_account(), chargingRule.getType(),
		    pool_ability_id, displayNum, usePlatNbr, number_vest);
	    if (poolAbilityInfo == null) {
		if (chargingRule.getType().startsWith("RongLian")) {
		    poolAbilityInfo = new PoolAbilityInfoBean();
		} else {
		    object.put("result", "-1");
		    object.put("errorMsg", "未配置对应显号;ability_type:" + chargingRule.getType());
		    object.put("describe", "未配置显号");
		    object.put("code", "0018");
		    return object;
		}
	    }

	    // 根据查询的账户默认调用的能力配置，调用相应的通道
	    // 判断如果是ims文字语音信息，则调用ims文字语音信息接口
	    if (AbilityTypeEnum.VOICENOTICE3.getKey().equals(chargingRule.getType())) {
		// 进行相应业务处理
		object = sendNoticeLet(poolAbilityInfo, voice_id, appExtendBean, accountBean, userIdentify, caller, called, schedule_send_time, push_url, chargingRule.getType(),
			tts_content, pool_ability_id, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("RongLian")) {
		object = sendNoticeLet(poolAbilityInfo, voice_id, appExtendBean, accountBean, userIdentify, caller, called, schedule_send_time, push_url, chargingRule.getType(),
			tts_content, pool_ability_id, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("TianYi")) {
		object = sendNoticeLet(poolAbilityInfo, voice_id, appExtendBean, accountBean, userIdentify, caller, called, schedule_send_time, push_url, chargingRule.getType(),
			tts_content, pool_ability_id, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("TianRun")) {
		object = sendNoticeLet(poolAbilityInfo, voice_id, appExtendBean, accountBean, userIdentify, caller, called, schedule_send_time, push_url, chargingRule.getType(),
			tts_content, pool_ability_id, batch_number, calledJsonArray);
	    } else if (chargingRule.getType().startsWith("YonYou")) {
		object = sendNoticeLet(poolAbilityInfo, voice_id, appExtendBean, accountBean, userIdentify, caller, called, schedule_send_time, push_url, chargingRule.getType(),
			tts_content, pool_ability_id, batch_number, calledJsonArray);
	    } else {
		object.put("result", "-1");
		object.put("errorMsg", "未配置默认文字语音信息通道！voice_type:" + chargingRule.getType());
		object.put("describe", "未配置线路");
		object.put("code", "0010");
	    }
	    /**
	     * 发起成功后调用信控入口服务 需要同时满足以下几个条件 1）语音通知发起成功 2）批次号不能为空
	     */
/*	    try {
		if (StringUtils.isNotEmpty(batch_number) && "0".equals(object.getString("result"))) {
		    String voiceIds = object.getString("voice_id");
		    if (StringUtils.isNotEmpty(voiceIds)) {
			String[] calleds = called.split(",");
			JSONObject voices = JSONObject.fromObject(voiceIds);
			String voiceId = voices.getString(calleds[0]);
			IInfoControl ifControl = new InfoControlServiceImpl();
			IfControlBean ifBean = new IfControlBean();
			ifBean.setAbilityType(chargingRule.getType());// 能力类型
			ifBean.setProductCode(AbilityTypeEnum.VOICE.getKey());
			ifBean.setAppKey(appExtendBean.getApp_key());// 应用标识
			ifBean.setCustAccount(accountBean.getCust_account());// 计费账户
			ifBean.setUserIdentify(userIdentify);// 用户id
			ifBean.setBatchNumber(batch_number);// 批次号
			ifBean.setRequestCount(calleds.length);// 本次调用传入的手机号数量
			Map<String, String> parameterMap = new HashMap<String, String>();
			parameterMap.put("voice_id", voiceId);// 调用重发接口
			parameterMap.put("source", poolAbilityInfo.getNumber_source());// 号码来源类型
			ifControl.infoControl(ifBean, parameterMap);
		    }
		}
	    } catch (Exception err) {
		log.error("信控监控异常", err);
		object.put("result", "-1");
		object.put("errorMsg", "重发失败：" + err.getMessage());
		object.put("describe", "语音通知异常");
		object.put("code", "0501");
	    }*/
	} else {
	    object.put("result", "-1");
	    object.put("describe", "能力配置错误");
	    object.put("code", "0013");
	}
	return object;
    }

    /**
     * * 重发语音短信实际业务处理
     * 
     * @param poolAbilityInfo
     * @param voice_id
     * @param appExtendBean
     * @param accountBean
     * @param userIdentify
     * @param caller
     * @param called
     * @param schedule_send_time
     * @param push_url
     * @param voice_type
     * @param tts_content
     *            前导音 如果设置前导音为-1，则使用之前的前导音如果前导音设置为空，则清空前导音
     * @param pool_ability_id
     * @param batch_number
     * @param calledJsonArray
     * @return
     */
    private JSONObject sendNoticeLet(PoolAbilityInfoBean poolAbilityInfo, String voice_id, AppExtendBean appExtendBean, AccountBean accountBean, String userIdentify,
	    String caller, String called, String schedule_send_time, String push_url, String voice_type, String tts_content, String pool_ability_id, String batch_number,
	    JSONArray calledJsonArray) {

	// 最终返回结果
	JSONObject object = new JSONObject();
	SendNotice sendNoticeOld = null;
	// 查询需要重发的信息
	sendNoticeOld = mSendNoticeDao.querySendNoticeByMeetId(coreDao, voice_id);

	if (sendNoticeOld == null) {
	    object.put("result", "-1");
	    object.put("describe", "未找到相应的信息" + voice_id);
	    object.put("code", "0512");
	} else {
	    object.put("result", "0");
	    object.put("describe", "发起语音短信存储成功");
	    object.put("code", "0000");
	    if (tts_content.equals("-1")) {
		tts_content = sendNoticeOld.getTts_content();
	    }
	    JSONObject voiceAndSessionIds = SendVoiceUtil.saveNotices(called, voice_type, appExtendBean.getApp_key(), caller, poolAbilityInfo.getCharge_number(),
		    poolAbilityInfo.getCharge_key(), accountBean.getCust_account(), appExtendBean.getPeriphery_code(), userIdentify, schedule_send_time, "",
		    sendNoticeOld.getContent(), sendNoticeOld.getVoice_name(), push_url, tts_content, poolAbilityInfo.getDisplay_number(), batch_number, "-1", "", "", coreDao,
		    calledJsonArray);
	    /**
		 * qinfx 2017-05-22 新增返回session_id
		 */
		JSONObject voice_ids = voiceAndSessionIds.getJSONObject("voiceIds");
		JSONObject session_ids = voiceAndSessionIds.getJSONObject("sessionIds");

		// 拼入返回的会议id
		object.put("voice_id", voice_ids.toString());
		object.put("session_id", session_ids.toString());
	}

	return object;
    }

    /**
     * 重发接口，根据VOICE_ID重发（自用接口）
     * 
     * @param app_key
     * @param cust_account
     * @param voice_id
     * @param called
     * @param userId
     * @param push_url
     * @return
     */
    public JSONObject sendVoiceNoticeByVoiceId(String app_key, String cust_account, String voice_id, String called, String userId, String push_url, JSONArray calledJsonArray) {
	JSONObject object = new JSONObject();
	SendNotice sendNoticeOld = mSendNoticeDao.querySendNoticeByMeetId(coreDao, voice_id);
	if (sendNoticeOld == null) {
	    object.put("result", "-1");
	    object.put("describe", "未找到相应的信息" + voice_id);
	    object.put("code", "0512");
	}
	String content = "";
	if (sendNoticeOld.getVoice_type().startsWith(AbilityTypeEnum.RONGLIANAUDEO.getKey()) || sendNoticeOld.getVoice_type().startsWith(AbilityTypeEnum.TIANYIAUDEO.getKey())) {
	    content = "";
	} else {
	    content = sendNoticeOld.getContent();
	}
	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Date now = new Date();
	String schedule_send_time = format.format(now);

	JSONObject voiceAndSessionIds = SendVoiceUtil.saveNotices(called, sendNoticeOld.getVoice_type(), app_key, sendNoticeOld.getCallee(), sendNoticeOld.getChargeNmr(),
		sendNoticeOld.getChargeKey(), cust_account, sendNoticeOld.getPeriphery_code(), userId, schedule_send_time, "", content, sendNoticeOld.getVoice_name(), push_url,
		sendNoticeOld.getTts_content(), sendNoticeOld.getDisplayNumber(), "", "-1", "", "", coreDao, calledJsonArray);
	/**
	 * qinfx 2017-05-22 新增返回session_id
	 */
	JSONObject voice_ids = voiceAndSessionIds.getJSONObject("voiceIds");
	JSONObject session_ids = voiceAndSessionIds.getJSONObject("sessionIds");

	// 拼入返回的会议id
	object.put("voice_id", voice_ids.toString());
	object.put("session_id", session_ids.toString());
	object.put("result", "0");
	object.put("describe", "发起语音短信存储成功");
	object.put("code", "0000");
	return object;
    }

    /**
     * 取消语音通知发送
     * 
     * @param app_key
     * @param cust_account
     * @param voice_id
     * @param batch_number
     * @return
     */
    public JSONObject cancelVoiceNotice(String app_key, String cust_account, String voice_id, String batch_number,String sessionId) {
	JSONObject object = new JSONObject();
	SendNotice sendNotice = new SendNotice();
	sendNotice.setApp_key(app_key);
	sendNotice.setCust_account(cust_account);
	sendNotice.setBatch_number(batch_number);
	if (StringUtils.isNotBlank(voice_id)) {
	    sendNotice.setMeet_ims_id(Integer.parseInt(voice_id));
	}
	sendNotice.setSession_id(sessionId);
	int flag = mSendNoticeDao.updateSendTime2(coreDao, sendNotice);
	if (flag > 0) {
	    object.put("result", "0");
	    object.put("describe", "取消语音通知发送成功");
	    object.put("code", "0000");
	} else {
	    object.put("result", "-1");
	    object.put("describe", "取消语音通知发送失败");
	    object.put("code", "0513");
	}
	return object;
    }
}
